﻿using Furion.JsonSerialization;
using Microsoft.AspNetCore.Mvc.Filters;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoUser.Application.User.Filter
{
    public class SystemInterceptorAttribute: ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            string actionname = App.HttpContext.Request.Path.Value;
            var request = JSON.Serialize(context.ActionArguments);
            
            Console.WriteLine(actionname);
            Console.WriteLine(request);

            JsonResult json = (JsonResult)context.Result;
            object o = json.Value;
            Console.WriteLine(o);

            Console.WriteLine(json);
            base.OnActionExecuting(context);
        }

        //public override Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        //{
        //    // 代码参考接口方式
        //    //获取context.Result具体类型
        //    //Console.WriteLine(context.Result.GetType());
        //    JsonResult result = (JsonResult)context.Result;
        //    Console.WriteLine(result.Value.GetType());
        //    Object o = (Object)result.Value;
        //    Console.WriteLine(o.GetType());
        //    Console.WriteLine(o);


        //    return base.OnResultExecutionAsync(context, next);
        //}

    }
}
